#include <QCoreApplication>
#include<iostream>
#include<QDebug>
class pizza
{public:
    virtual void productpizza()=0;
    virtual ~pizza(){}
};
class drink
{
public:
    virtual void productdrink()=0;
    virtual ~drink(){}
};

class Chinapizza: public pizza{
public:
    void productpizza()
    {
        qDebug()<<"中国披萨";
    }
};
class Chinadrink:public drink{
public:
    void productdrink()
    {
        qDebug()<<"中国饮料";
    }
};
class NewYorkPizza : public pizza {
public:
    void productpizza() override {
        qDebug() << "准备纽约风味薄饼披萨：薄脆饼底，大量芝士" ;
    }

};

class NewYorkDrink : public drink {
public:
    void productdrink() override {
        qDebug() << "提供纽约特色苏打水" ;
    }
};
//工厂接口
class PizzaStoreFactory {
public:
    virtual pizza* createPizza() = 0;
    virtual drink* createDrink() = 0;
    ~PizzaStoreFactory(){}
};
// 5. 具体工厂 - 负责创建一整套配套产品
class NewYorkStoreFactory : public PizzaStoreFactory {
public:
    pizza* createPizza() override {
        return new NewYorkPizza();
    }
    drink* createDrink() override {
        return new NewYorkDrink();
    }

};
class ChinaStoreFactory : public PizzaStoreFactory {
public:
    pizza* createPizza() override {
        return new Chinapizza();
    }
    drink* createDrink() override {
        return new Chinadrink();
    }

};



int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Set up code that uses the Qt event loop here.
    // Call a.quit() or a.exit() to quit the application.
    // A not very useful example would be including
    // #include <QTimer>
    // near the top of the file and calling
    // QTimer::singleShot(5000, &a, &QCoreApplication::quit);
    // which quits the application after 5 seconds.

    // If you do not need a running Qt event loop, remove the call
    // to a.exec() or use the Non-Qt Plain C++ Application template.

    PizzaStoreFactory*factory;
    factory=new NewYorkStoreFactory();
    pizza* piz=factory->createPizza();
    drink* drk=factory->createDrink();
    piz->productpizza();
    drk->productdrink();
    delete drk;
    delete piz;
    delete factory;

    return a.exec();
}
